package jech913.basic;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class JoinMember
 */
@WebServlet("/JoinMember.do")
public class JoinMember extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
		// TODO Auto-generated method stub
		res.setContentType("text/html; charset=UTF-8");
		PrintWriter out = res.getWriter();
		
	
		out.print("<html>");
		out.print("<head><title> 회원가입 </title></head>");
		out.print("<body><h1> 회원가입 </h1>");
		out.print("<form name='join' method='post' >");
		out.print("<div> 아이디 <input type='text' name='userid' > </div> <br/>");
		out.print("<div> 비밀번호 <input type='password' name='pwd' > </div> <br/>");
		out.print("<div> 비밀번호 확인 <input type='password' name='repwd' > </div> <br/>");
		out.print("<div> 이름 <input type='text' name='username' > </div> <br/>");
		out.print("<div> 전자우편 <input type='mail' name='mailaddr' > </div><br/><br/>");
		
		out.print("<div> <button type='submit'> 입력완료 </button> &nbsp;");
		out.print("<button type='reset'> 다시입력 </button> </div>");
		out.print("</form>");			
		out.print("</body>");
		out.print("</html>");
		
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
		// TODO Auto-generated method stub
		res.setContentType("text/html; charset=UTF-8");
		PrintWriter out = res.getWriter();
		
		
		//요청 객체에 대해 한글처리 
		req.setCharacterEncoding("UTF-8");
		
		
		String id = req.getParameter("userid");
		String pwd = req.getParameter("pwd");
		String repwd = req.getParameter("repwd");
		String name = req.getParameter("username");
		String mail = req.getParameter("mailaddr");
		
		
		out.print("<html>");
		out.print("<head><title> 회원정보 </title></head>");
		out.print("<body><h1> 회원정보 </h1>");
		out.print("아이디: " + id + "</br>");
		out.print("이름: " + name + "</br>");
		out.print("전자우편: " + mail + "</br>");
		out.print("</p>");
		out.print("<hr/>");
		out.print("<h3> 회원가입이 완료 되었습니다 </h3>");
		out.print("</body>");
		out.print("</html>");
	}

}
